import {
  Blog,
  BlogGetParam,
  BlogPageParam,
  BlogRemoveParam,
  BlogSaveOrUpdateParam,
  BlogStatusChangeParam,
  BlogTopParam,
} from '@/types'

import { PageData } from '@/types/resp.ts'
import request from '@/utils/request'

export const page = (param: BlogPageParam): Promise<PageData<Blog>> => {
  return request({
    url: '/blog/page',
    method: 'post',
    data: param,
  })
}

export const saveOrUpdate = (param: BlogSaveOrUpdateParam): Promise<Blog> => {
  return request({
    url: '/blog/saveOrUpdate',
    method: 'post',
    data: param,
  })
}

export const remove = (param: BlogRemoveParam): Promise<unknown> => {
  return request({
    url: '/blog/remove',
    method: 'post',
    data: param,
  })
}

export const push = (param: BlogRemoveParam): Promise<unknown> => {
  return request({
    url: '/blog/push',
    method: 'post',
    data: param,
  })
}

export const statusChange = (param: BlogStatusChangeParam): Promise<unknown> => {
  return request({
    url: '/blog/status/change',
    method: 'post',
    data: param,
  })
}

export const top = (param: BlogTopParam): Promise<unknown> => {
  return request({
    url: '/blog/top',
    method: 'post',
    data: param,
  })
}

export const get = (param: BlogGetParam): Promise<Blog> => {
  return request({
    url: '/blog/get',
    method: 'post',
    data: param,
  })
}
